package com.cn.qtms.service.codename;//类注释设置模板

import com.cn.qtms.common.codename.CodeNameItem;
import com.cn.qtms.entity.TmSecGoods;
import com.cn.qtms.util.DateUtils;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @Name:CodeNameServiceImpl
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-12-26 17:36
 **/
@Service
public class CodeNameServiceImpl implements CodeNameService {
    @Override
    public List<CodeNameItem> weeks() {
        List<CodeNameItem> list = new ArrayList<>();
        CodeNameItem item1 = new CodeNameItem("星期一", TmSecGoods.MON_DAY, "");
        CodeNameItem item2 = new CodeNameItem("星期二", TmSecGoods.TUES_DAY, "");
        CodeNameItem item3 = new CodeNameItem("星期三", TmSecGoods.WED_DAY, "");
        CodeNameItem item4 = new CodeNameItem("星期四", TmSecGoods.THUR_DAY, "");
        CodeNameItem item5 = new CodeNameItem("星期五", TmSecGoods.FRI_DAY, "");
        CodeNameItem item6 = new CodeNameItem("星期六", TmSecGoods.SAT_DAY, "");
        CodeNameItem item7 = new CodeNameItem("星期日", TmSecGoods.SUN_DAY, "");
        list.add(item1);
        list.add(item2);
        list.add(item3);
        list.add(item4);
        list.add(item5);
        list.add(item6);
        list.add(item7);
        return list;
    }

    /**
     * 秒杀场次信息下拉框 固定时间的
     *
     * @return
     */
    @Override
    public List<CodeNameItem> actTypes() {
        List<CodeNameItem> list = new ArrayList<>();
        CodeNameItem item1 = new CodeNameItem("10点场 10:00-12:00", 1, "10:00:00-12:00:00");
        CodeNameItem item2 = new CodeNameItem("12点场 12:00-14:00", 2, "12:00:00-14:00:00");
        CodeNameItem item3 = new CodeNameItem("18点场 18:00-20:00", 3, "18:00:00-20:00:00");
        CodeNameItem item4 = new CodeNameItem("20点场 20:00-22:00", 4, "20:00:00-22:00:00");
        list.add(item1);
        list.add(item2);
        list.add(item3);
        list.add(item4);
        return list;
    }

    @Override
    public List<CodeNameItem> nowActType() {
        final Calendar instance = Calendar.getInstance();
        final int hour = instance.get(Calendar.HOUR_OF_DAY);
        //name中储存的是redis的键值
        if (0 <= hour && hour < 10) {
            List<CodeNameItem> list = new ArrayList<>();
            list.add(new CodeNameItem("yesterday_4", "20点场 20:00-22:00", 1, "前日已结束"));
            list.add(new CodeNameItem("today_1", "10点场 10:00-12:00", 2, "预告"));
            list.add(new CodeNameItem("today_2", "12点场 12:00-14:00", 3, "预告"));
            list.add(new CodeNameItem("today_3", "18点场 18:00-20:00", 4, "预告"));
            return list;
        } else if (hour >= 10 && hour < 12) {
            List<CodeNameItem> list = new ArrayList<>();
            list.add(new CodeNameItem("yesterday_4", "20点场 20:00-22:00", 1, "前日已结束"));
            list.add(new CodeNameItem("today_1", "10点场 10:00-12:00", 2, "正在进行"));
            list.add(new CodeNameItem("today_2", "12点场 12:00-14:00", 3, "预告"));
            list.add(new CodeNameItem("today_3", "18点场 18:00-20:00", 4, "预告"));
            return list;
        } else if (hour >= 12 && hour < 14) {
            List<CodeNameItem> list = new ArrayList<>();
            list.add(new CodeNameItem("today_1", "10点场 10:00-12:00", 1, "已结束"));
            list.add(new CodeNameItem("today_2", "12点场 12:00-14:00", 2, "正在进行"));
            list.add(new CodeNameItem("today_3", "18点场 18:00-20:00", 3, "预告"));
            list.add(new CodeNameItem("today_4", "20点场 20:00-22:00", 4, "预告"));
            return list;
        } else if (hour >= 14 && hour < 18) {
            List<CodeNameItem> list = new ArrayList<>();
            list.add(new CodeNameItem("today_2", "12点场 12:00-14:00", 1, "已结束"));
            list.add(new CodeNameItem("today_3", "18点场 18:00-20:00", 2, "预告"));
            list.add(new CodeNameItem("today_4", "20点场 20:00-22:00", 3, "预告"));
            list.add(new CodeNameItem("tomorrow_1", "10点场 10:00-12:00", 4, "次日预告"));
            return list;
        }else if(hour>=18 && hour<20){
            List<CodeNameItem> list = new ArrayList<>();
            list.add(new CodeNameItem("today_2", "12点场 12:00-14:00", 1, "已结束"));
            list.add(new CodeNameItem("today_3", "18点场 18:00-20:00", 2, "正在进行"));
            list.add(new CodeNameItem("today_4", "20点场 20:00-22:00", 3, "预告"));
            list.add(new CodeNameItem("tomorrow_1", "10点场 10:00-12:00", 4, "次日预告"));
            return list;
        }else if(hour>=20 && hour<22){
            List<CodeNameItem> list = new ArrayList<>();
            list.add(new CodeNameItem("today_3", "18点场 18:00-20:00", 1, "已结束"));
            list.add(new CodeNameItem("today_4", "20点场 20:00-22:00", 2, "正在进行"));
            list.add(new CodeNameItem("tomorrow_1", "10点场 10:00-12:00", 3, "次日预告"));
            list.add(new CodeNameItem("tomorrow_2", "12点场 12:00-14:00", 4, "次日预告"));
            return list;
        }else if(hour>=22){
            List<CodeNameItem> list = new ArrayList<>();
            list.add(new CodeNameItem("today_4", "20点场 20:00-22:00", 1, "已结束"));
            list.add(new CodeNameItem("tomorrow_1", "10点场 10:00-12:00", 2, "次日预告"));
            list.add(new CodeNameItem("tomorrow_2", "12点场 12:00-14:00", 3, "次日预告"));
            list.add(new CodeNameItem("tomorrow_3", "18点场 18:00-20:00", 4, "次日预告"));
            return list;
        }
        return null;
    }


    /**
     * 会员等级
     *
     * @return
     */
    @Override
    public List<CodeNameItem> levels() {
        List<CodeNameItem> list = new ArrayList<>();
        CodeNameItem item1 = new CodeNameItem("V0", 0, "");
        CodeNameItem item2 = new CodeNameItem("V1", 1, "");
        CodeNameItem item3 = new CodeNameItem("V2", 2, "");
        CodeNameItem item4 = new CodeNameItem("V3", 3, "");
        CodeNameItem item5 = new CodeNameItem("V4", 4, "");
        CodeNameItem item6 = new CodeNameItem("V5", 5, "");
        CodeNameItem item7 = new CodeNameItem("银卡", 6, "");
        CodeNameItem item8 = new CodeNameItem("金卡", 7, "");
        CodeNameItem item9 = new CodeNameItem("白金卡", 8, "");
        CodeNameItem item10 = new CodeNameItem("钻石卡", 9, "");
        list.add(item1);
        list.add(item2);
        list.add(item3);
        list.add(item4);
        list.add(item5);
        list.add(item6);
        list.add(item7);
        list.add(item8);
        list.add(item9);
        list.add(item10);
        return list;
    }

    /**
     * 获取当前是周几 周日TmSecGoods.SUN_DAY 周二
     */
    @Override
    public String getWeek(Calendar cal) {
        final int i = cal.get(Calendar.DAY_OF_WEEK);
        if (i == Calendar.SUNDAY) {
            return TmSecGoods.SUN_DAY;
        } else if (i == Calendar.MONDAY) {
            return TmSecGoods.MON_DAY;
        } else if (i == Calendar.TUESDAY) {
            return TmSecGoods.TUES_DAY;
        } else if (i == Calendar.WEDNESDAY) {
            return TmSecGoods.WED_DAY;
        } else if (i == Calendar.THURSDAY) {
            return TmSecGoods.THUR_DAY;
        } else if (i == Calendar.FRIDAY) {
            return TmSecGoods.FRI_DAY;
        } else if (i == Calendar.SATURDAY) {
            return TmSecGoods.SAT_DAY;
        }
        return null;
    }
}
